package org.fluidripple.socket.protocol;

import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import org.fluidripple.socket.wrapper.DataWrapper;

public abstract class Protocol {

    public abstract void writer(Channel channel);

    public abstract void toDecode(DataWrapper dataWrapper);

    public void decode(DataWrapper dataWrapper){
        toDecode(dataWrapper);
        ByteBuf buf = dataWrapper.getBuf();
        int readabled = buf.readableBytes();
        if(readabled > 0){
            buf.skipBytes(readabled);
        }
    }
}
